package org.example.petitionplatformsystem.service.Impl;

import org.example.petitionplatformsystem.dao.DelayRequestsRepository;
import org.example.petitionplatformsystem.dao.model.DelayRequests;
import org.example.petitionplatformsystem.service.DelayRequestsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DelayRequestsServiceImpl implements DelayRequestsService {
    @Autowired
    private DelayRequestsRepository delayRequestsRepository;

    @Override
    public void addDelayRequest(DelayRequests delayRequest) {
        delayRequestsRepository.save(delayRequest);
    }

    @Override
    public void updateDelayRequest(DelayRequests delayRequest) {
        delayRequestsRepository.save(delayRequest);
    }

    @Override
    public void deleteDelayRequest(DelayRequests delayRequest) {
        delayRequestsRepository.delete(delayRequest);
    }

    @Override
    public DelayRequests getDelayRequestById(long id) {
        return delayRequestsRepository.findById(id).orElse(null);
    }

    @Override
    public List<DelayRequests> getAllDelayRequests() {
        return delayRequestsRepository.findAll();
    }
}
